﻿// -----------------------------------------------------------------------
// <copyright file="Adapter_Tests.cs" company="CompDJ">
//     Copyright (c) CompDJ. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------
namespace CompDJ.Web.Abstractions.UnitTests
{
    using System;
    using CompDJ.Web.Abstractions;
    using CompDJ.Web.Abstractions.UnitTests;
    using FluentAssertions;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class Adapter_Tests
    {
        /// <summary>A unit test initialization method</summary>
        /// <remarks>Needed because we are using static classes for the factories</remarks>
        [TestInitialize]
        public void TestInitialize()
        {
            WebAbstractions.Factory.ResetAllFactories();
        }
        
        /// <summary>A unit test method</summary>
        [TestMethod, TestCategory("UnitTests"), TestCategory("FormsAuthenticationFactory"),
        Description("FormsAuthenticationFactory.Current.GetType() - Should be typeof(FormsAuthenticationAdapter)")]
        public void FormsAuthenticationFactory_Current_Type_ShouldBe_FormsAuthenticationAdapter()
        {
            Type expected = typeof(FormsAuthenticationAdapter);
            Type actual = FormsAuthenticationFactory.Current.GetType();

            actual.Should().Be(expected);
        }

        /// <summary>A unit test method</summary>
        [TestMethod, TestCategory("UnitTests"), TestCategory("ConfigurationManagerFactory"),
        Description("ConfigurationManagerFactory.Current.GetType() - Should be typeof(ConfigurationManagerAdapter)")]
        public void ConfigurationManagerFactory_Current_Type_ShouldBe_ConfigurationManagerAdapter()
        {
            Type expected = typeof(ConfigurationManagerAdapter);
            Type actual = ConfigurationManagerFactory.Current.GetType();

            actual.Should().Be(expected);
        }

        /// <summary>A unit test method</summary>
        [TestMethod, TestCategory("UnitTests"), TestCategory("MembershipAdapter"),
        Description("MembershipAdapter.Current.GetType() - Should be typeof(MembershipAdapter)")]
        public void MembershipAdapter_Current_Type_ShouldBe_MembershipAdapter()
        {
            Type expected = typeof(MembershipAdapter);
            Type actual = MembershipFactory.Current.GetType();

            actual.Should().Be(expected);
        }

        /// <summary>A unit test method</summary>
        [TestMethod, TestCategory("UnitTests"), TestCategory("HttpContextFactory"),
        Description("HttpContextFactory.Current - Target should be null")]
        public void HttpContextFactory_Current_Target_ShouldBeNull()
        {
            var target = HttpContextFactory.Current;
            
            target.Should().BeNull();
        }
    }
}
